--------------------------------------------------------------------------------
      name:  <unnamed>
       log:  
  log type:  text
 opened on:   5 Nov 2018, 09:26:49

. 
. foreach x in "table 1" "table 2" "table A1" "figure A1" {
  2.         do "`x'"
  3. }

. /*****************************************************************************
> **
> This file replicates Table 1. Specifically, it produces the final column of Ta
> bl
> e 1 only. 
> ******************************************************************************
> */
. 
. use dataset, clear

. tab studynumber

studynumber |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      1,035       26.19       26.19
          2 |        974       24.65       50.84
          3 |        653       16.52       67.36
          4 |        633       16.02       83.38
          5 |        606       15.33       98.71
          6 |         51        1.29      100.00
------------+-----------------------------------
      Total |      3,952      100.00

. 
end of do-file

. /*****************************************************************************
> **
> This file replicates Table 2.
> ******************************************************************************
> */
. 
. use dataset, clear

. gen adtarget = ""
(3,952 missing values generated)

. gen study = .
(3,952 missing values generated)

. gen n = .
(3,952 missing values generated)

. gen match = .
(3,952 missing values generated)

. 
. *** loop over the target-study combinations ***
. 
. local demographics = "age1824_4 age25plus_4 noba_4 baorhigher_4 white_2 black_
> 2" 

. local behavior = "veryliberal_5 liberal_5 democrat_5 donate_5"

. local location = "atlanta_3 charlotte_3 memphis_4 memphis_2 seattle_3 stpeters
> burg_3 toledo_3 zip_1 zip_2 zip_6"

. 
. local k = 1

. local m = 1

. qui: {

. 
. *** formatting tweaks ***
. 
. replace match = round(match, .001)
(20 real changes made)

. replace match = match*100
(20 real changes made)

. format match %20.01fc

. format n %20.00fc

. 
. replace adtarget = "Age: 18-24" if adtarget == "age1824"
(1 real change made)

. replace adtarget = "Age: 25+" if adtarget == "age25plus"
(1 real change made)

. replace adtarget = "Education: Less than BA" if adtarget == "noba"
variable adtarget was str20 now str23
(1 real change made)

. replace adtarget = "Education: BA or Higher" if adtarget == "baorhigher"
(1 real change made)

. replace adtarget = "Race: White" if adtarget == "white"
(1 real change made)

. replace adtarget = "Race: Black" if adtarget == "black"
(1 real change made)

. replace adtarget = "Ideology: Very Liberal" if adtarget == "veryliberal"
(1 real change made)

. replace adtarget = "Ideology: Liberal" if adtarget == "liberal"
(1 real change made)

. replace adtarget = "Party: Democrat" if adtarget == "democrat"
(1 real change made)

. replace adtarget = "Donate to Liberal Causes" if adtarget == "donate"
variable adtarget was str23 now str24
(1 real change made)

. replace adtarget = "City: Atlanta, GA" if adtarget == "atlanta"
(1 real change made)

. replace adtarget = "City: Charlotte, NC" if adtarget == "charlotte" 
(1 real change made)

. replace adtarget = "City: Memphis, TN" if adtarget == "memphis" 
(2 real changes made)

. replace adtarget = "City: Seattle, WA" if adtarget == "seattle" 
(1 real change made)

. replace adtarget = "City: St. Petersburg, FL" if adtarget == "stpetersburg" 
(1 real change made)

. replace adtarget = "City: Toledo, OH" if adtarget == "toledo" 
(1 real change made)

. replace adtarget = "Zip Code: 1,244 Codes" if adtarget == "zip" & study == 1
(1 real change made)

. replace adtarget = "Zip Code: 12 Codes" if adtarget == "zip" & study == 2
(1 real change made)

. replace adtarget = "Zip Code: 40 Codes" if adtarget == "zip" & study == 6
(1 real change made)

. 
. tostring study, replace
study was float now str1

. replace study = "I" if study == "1"
(1 real change made)

. replace study = "II" if study == "2"
variable study was str1 now str2
(4 real changes made)

. replace study = "III" if study == "3"
variable study was str2 now str3
(5 real changes made)

. replace study = "IV" if study == "4"
(5 real changes made)

. replace study = "V" if study == "5"
(4 real changes made)

. replace study = "VI" if study == "6"
(1 real change made)

. replace study = "" if study == "."
(3,932 real changes made)

. 
. replace adtarget = "~~~~" + adtarget if study != ""
variable adtarget was str24 now str28
(20 real changes made)

. 
. *** output ***
. 
. keep if !mi(adt)
(3,929 observations deleted)

. keep adtarget study n match

. list  

     +------------------------------------------------------+
     |                     adtarget   study       n   match |
     |------------------------------------------------------|
  1. |         \emph{Demographics:}               .       . |
  2. |               ~~~~Age: 18-24      IV      78    91.0 |
  3. |                 ~~~~Age: 25+      IV     551    99.8 |
  4. |  ~~~~Education: Less than BA      IV     283    67.8 |
  5. |  ~~~~Education: BA or Higher      IV     350    73.7 |
     |------------------------------------------------------|
  6. |              ~~~~Race: White      II     176    92.6 |
  7. |              ~~~~Race: Black      II     547    23.4 |
  8. |             \emph{Behavior:}               .       . |
  9. |   ~~~~Ideology: Very Liberal       V      34    97.1 |
 10. |        ~~~~Ideology: Liberal       V      34    79.4 |
     |------------------------------------------------------|
 11. |          ~~~~Party: Democrat       V     493    58.8 |
 12. | ~~~~Donate to Liberal Causes       V      44    38.6 |
 13. |             \emph{Location:}               .       . |
 14. |        ~~~~City: Atlanta, GA     III     124    81.5 |
 15. |      ~~~~City: Charlotte, NC     III     138    97.8 |
     |------------------------------------------------------|
 16. |        ~~~~City: Memphis, TN      IV     633    96.5 |
 17. |        ~~~~City: Memphis, TN      II     974    97.3 |
 18. |        ~~~~City: Seattle, WA     III     128    93.0 |
 19. | ~~~~City: St. Petersburg, FL     III     131    98.5 |
 20. |         ~~~~City: Toledo, OH     III     132    98.5 |
     |------------------------------------------------------|
 21. |    ~~~~Zip Code: 1,244 Codes       I   1,035    96.8 |
 22. |       ~~~~Zip Code: 12 Codes      II     243    44.0 |
 23. |       ~~~~Zip Code: 40 Codes      VI      51    78.4 |
     +------------------------------------------------------+

. 
. #delimit;
delimiter now ;
.         listtex 
>                 using "table 2.tex"
>                 ,
>                 replace
>                 type rstyle(tabular)
>                 head(
>                         \begin{tabular*}{\hsize}{@{\hskip\tabcolsep\extracolse
> p\fill}l*{4}{c}}
>                         \toprule Ad Target&Study&Recruited (N)&Match Rate (\%)
> \\
>                         \midrule
>                 )
>                 foot("\bottomrule\end{tabular*}")
>                 ;
\begin{tabular*}{\hsize}{@{\hskip\tabcolsep\extracolsep\fill}l*{4}{c}}
\toprule
Ad
Target&Study&Recruited
(N)&Match
Rate
(\%)\\
\midrule
\emph{Demographics:}&&&\\
~~~~Age: 18-24&IV&78&91.0\\
~~~~Age: 25+&IV&551&99.8\\
~~~~Education: Less than BA&IV&283&67.8\\
~~~~Education: BA or Higher&IV&350&73.7\\
~~~~Race: White&II&176&92.6\\
~~~~Race: Black&II&547&23.4\\
\emph{Behavior:}&&&\\
~~~~Ideology: Very Liberal&V&34&97.1\\
~~~~Ideology: Liberal&V&34&79.4\\
~~~~Party: Democrat&V&493&58.8\\
~~~~Donate to Liberal Causes&V&44&38.6\\
\emph{Location:}&&&\\
~~~~City: Atlanta, GA&III&124&81.5\\
~~~~City: Charlotte, NC&III&138&97.8\\
~~~~City: Memphis, TN&IV&633&96.5\\
~~~~City: Memphis, TN&II&974&97.3\\
~~~~City: Seattle, WA&III&128&93.0\\
~~~~City: St. Petersburg, FL&III&131&98.5\\
~~~~City: Toledo, OH&III&132&98.5\\
~~~~Zip Code: 1,244 Codes&I&1,035&96.8\\
~~~~Zip Code: 12 Codes&II&243&44.0\\
~~~~Zip Code: 40 Codes&VI&51&78.4\\
\bottomrule\end{tabular*}

.                 #delimit cr
delimiter now cr
. 
end of do-file

. /*****************************************************************************
> **
> This file replicates Table A1.
> ******************************************************************************
> */
. 
. use dataset, clear

. 
. keep if studynumber == 6
(3,901 observations deleted)

. 
. eststo clear

. 
. eststo: reg zip passed, robust

Linear regression                               Number of obs     =         51
                                                F(1, 49)          =       3.12
                                                Prob > F          =     0.0835
                                                R-squared         =     0.0510
                                                Root MSE          =     .40876

------------------------------------------------------------------------------
             |               Robust
         zip |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      passed |   .1903226   .1077091     1.77   0.083     -.026127    .4067722
       _cons |   .7096774    .083172     8.53   0.000      .542537    .8768178
------------------------------------------------------------------------------
(est1 stored)

. eststo: reg passed raffle, cl(zipcode)

Linear regression                               Number of obs     =         51
                                                F(1, 32)          =       0.85
                                                Prob > F          =     0.3647
                                                R-squared         =     0.0207
                                                Root MSE          =      .4929

                               (Std. Err. adjusted for 33 clusters in zipcode)
------------------------------------------------------------------------------
             |               Robust
      passed |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      raffle |  -.1428571   .1553508    -0.92   0.365    -.4592963     .173582
       _cons |   .4761905   .1211365     3.93   0.000     .2294434    .7229376
------------------------------------------------------------------------------
(est2 stored)

. eststo: reg zip raffle, cl(zipcode)

Linear regression                               Number of obs     =         51
                                                F(1, 32)          =       0.09
                                                Prob > F          =     0.7694
                                                R-squared         =     0.0021
                                                Root MSE          =     .41917

                               (Std. Err. adjusted for 33 clusters in zipcode)
------------------------------------------------------------------------------
             |               Robust
         zip |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      raffle |   .0380952   .1288355     0.30   0.769    -.2243341    .3005246
       _cons |   .7619048   .1035054     7.36   0.000     .5510712    .9727383
------------------------------------------------------------------------------
(est3 stored)

. 
. label variable zip "Zip Code Matched"

. label variable passed "Passed Screener"

. label variable raffle "Incentives"

. 
. #delimit;
delimiter now ;
. esttab
>         using "table A1.tex"
>         ,
>                 replace
>                 se 
>                 nostar
>                 label
>                 stats(N, label("Sample size"))
>                 booktabs
>                 width(\textwidth)
>                 nonote
>                 ;
(output written to table A1.tex)

. #delimit cr
delimiter now cr
. 
end of do-file

. /*****************************************************************************
> **
> This file replicates Figure A1. 
> ******************************************************************************
> */
. 
. use dataset, clear

. 
. keep if studynumber == 6
(3,901 observations deleted)

. 
. collapse zip pctfb (count) n=zip, by(zipcode)

. 
. su pctfb

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       pctfb |         26    .6834253     .172325    .438866   .9934103

. 
. #delimit;
delimiter now ;
. gr tw
>         (lfitci zip pctfb, clcol(black))
>         (sc zip pctfb, mcol(black) msym(Oh))
>         ,
>                 legend(off)
>                 plotregion(style(none))
>                 xtitle("Proportion With Facebook Access")
>                 ytitle("Proportion With Matching Zip Code")
>                 ylab(0(.2)1, angle(horiz))
>                 ;

. #delimit cr
delimiter now cr
. 
. gr export "figure A1.png", replace width(1000)
(file figure A1.png written in PNG format)

. 
. su pctfb

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       pctfb |         26    .6834253     .172325    .438866   .9934103

. replace pctfb= (pctfb- r(mean))/r(sd)
(26 real changes made)

. reg zip pctfb, cl(zipcode)

Linear regression                               Number of obs     =         26
                                                F(1, 25)          =       0.70
                                                Prob > F          =     0.4099
                                                R-squared         =     0.0260
                                                Root MSE          =     .23851

                               (Std. Err. adjusted for 26 clusters in zipcode)
------------------------------------------------------------------------------
             |               Robust
         zip |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       pctfb |   .0381979   .0455754     0.84   0.410    -.0556663    .1320621
       _cons |   .9102564   .0467747    19.46   0.000     .8139221    1.006591
------------------------------------------------------------------------------

. 
end of do-file

. 
. log close
      name:  <unnamed>
       log:  
  log type:  text
 closed on:   5 Nov 2018, 09:26:49
--------------------------------------------------------------------------------
